//100. 相同的树
//思路：前序遍历思想判断两个树是否相同(如果根都不想等那么就不用比其他节点了)
#include <stdio.h>
#include <stdbool.h>

struct TreeNode {
	int val;
	struct TreeNode* left;
	struct TreeNode* right;
};
bool isSameTree(struct TreeNode* p, struct TreeNode* q) {
	if (NULL == p && NULL == q)
		return true;
	else if ((NULL != p && NULL == q)
		|| (NULL == p && NULL != q))
		return false;
	
	if (p->val != q->val)
		return false;

	return isSameTree(p->left, q->left)
		&& isSameTree(p->right, q->right);
}